home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Documentation / Development Notes / Compiling IDL Files < prev    next >
Encoding:
Text File  |  1996-08-16  |  7.4 KB  |  117 lines  |  [TEXT/ttxt]

  1. OpenDoc
  2. Development
  3. Framework
  4.                                                                                                                                                                                     
  5. Compiling IDL Files 
  6. ODF Release 1                                                                                                                                                             
  7.  
  8.  
  9. Table of Contents
  10. -----------------
  11. • Installing ToolServer and SOM
  12. • Compiling IDL Files (CodeWarrior)
  13. • Compiling IDL Files (Non-CodeWarrior)
  14.     • Installing
  15.     • Compiling
  16.     • Common Problems
  17.  
  18.  
  19. Installing ToolServer and SOM
  20.  
  21. To compile IDL files, you need to use the SOM compiler. SOM currently only runs as an MPW or ToolServer tool. If you are using a CodeWarrior or Symantec C++ then you should install ToolServer. ToolServer is available from ETO, MPW Pro, CodeWarrior Gold Reference, and Symantec C++.
  22.  
  23. Once you have ToolServer, you will need to install the SOM compiler. If it didn't come with your development environment then you can also get it from the OpenDoc CD. Inside the “SOMobjects™ for Mac OS” folder is a folder called “MPW Additions.” Copy the contents of this folder into your ToolServer folder. If you already have a folder with the same name as another folder in here, then add the contents to the existing folders. The UserStartup•somc (UserStartupTS•somc for ToolServer) file goes at the top level (same folder as ToolServer or MPW) or in the "Startup Items" folder.
  24.  
  25. In addition to installing ToolServer, CodeWarrior users should also install the “SOMobjects™ TS” plugin tool. This tool is located in the “Tools & Goodies: CodeWarrior Plugins : Compilers” folder on the ODF CD, and needs to be placed in the “CodeWarrior Plugins : Compilers” folder in your CodeWarrior folder. This is done for you by the ODF Installer.
  26.  
  27. Non-CodeWarrior users should copy the UserStartupTS•ODF (ToolServer) or UserStartup•ODF (MPW) file into ToolServer or MPW.
  28.  
  29.  
  30. Compiling IDL Files (CodeWarrior)
  31.  
  32. Once you’ve written a .idl file, add it to the CodeWarrior project. Compile it directly (with command-K) once. If it compiles without errors, it will have generated three new files, ending with .xih, .xh, and .cpp. Add the .cpp file to your project. This is where you will be implementing your extension.
  33.  
  34. If you ever need to change your .idl file, the SOM compiler is smart enough to modify your .cpp file in place. You don't have to worry about your code being deleted. In some cases it will create a new set of methods (for instance, if you rename your SOM class); other times it fixes prototypes for you, and even inserts comments telling you what it did. Sounds scary, but it works fine.
  35.  
  36. You may notice that you don't have to use ToolServer directly. The SOM plugin tool looks like a standard compiler to CodeWarrior, but in reality it sends AppleEvents to ToolServer to compile the .idl file. As far as CodeWarrior is concerned, the plugin tool is doing the compile. Eventually we plan to make the SOM compiler a true plugin, eliminating the need for ToolServer. However, since ToolServer is doing the compile and not CodeWarrior, it can’t read open windows which haven’t been saved to disk. Make sure to save your .idl file to disk before compiling it.
  37.  
  38. At the moment, the SOM plugin tool is not officially supported or tested. It seems to work for most people. If you have problems then you may need to remove the .idl file from the project window and use the Non-CodeWarrior approach below.
  39.  
  40.  
  41. Compiling IDL Files (Non-CodeWarrior)
  42.  
  43.  
  44. Compiling IDL files requires that you use MPW and SOM. Both of these are available on ETO and other development CDs.
  45.  
  46. Installing
  47.  
  48. • Install MPW
  49. • Copy the SOM SDK into the appropriate places in the MPW folders.
  50. • If you are not using CW or SC++, copy the OpenDoc SDK into the appropriate places in the MPW folders.
  51. • Copy UserStartup•ODF into your MPW folder.
  52. • Launch MPW
  53. • MPW will ask for the ODF folder. Go to it and press "Directory".
  54. • MPW will ask for the OpenDoc Headers. Go to them in your CW, SC++, or MPW folder and press "Directory".
  55.  
  56. • Lastly you need to fix one of the ODF build files. The way ODF is built causes us to comment out the build rules for .cpp files. Type this in MPW:
  57.         Open "{FWToolsDir}"MacMake.rul
  58. Now do a find on "HLX".  You will see 12 lines which have # signs in front of them. Remove the #s from lines (except the first one, with the HLX). Save this file and close it.
  59.  
  60. Compiling
  61.  
  62. • Add your .idl file to the MacMake.bmk file (the "Makefile")
  63. When you generated your part with PartMaker, it created the CodeWarrior project and an MPW makefile, called MacMake.bmk. The makefile lists all the output of the idl files, like so:
  64.  
  65. __ComponentSourcesFromIDL = ∂
  66.         "{_FWTargetDir}SOMPart.cpp" ∂
  67.         "{_FWTargetDir}SOMPart.xh"  ∂
  68.         "{_FWTargetDir}SOMPart.xih"
  69.  
  70. __ComponentObjects = ∂
  71.         "{_FWObjDir}"SOMPart.cpp.o
  72.  
  73. You don't list the .idl file in the makefile, instead you list the output files. The Make tool will determine how to build those output files based on our default rules.
  74.  
  75. If your idl file was called MyInterface.idl, you will add the output files to those definitions like this:
  76.  
  77. __ComponentSourcesFromIDL = ∂
  78.         "{_FWTargetDir}MyInterface.cpp" ∂
  79.         "{_FWTargetDir}MyInterface.xih" ∂
  80.         "{_FWTargetDir}MyInterface.xh" ∂
  81.         "{_FWTargetDir}SOMPart.cpp" ∂
  82.         "{_FWTargetDir}SOMPart.xh"  ∂
  83.         "{_FWTargetDir}SOMPart.xih"
  84.  
  85. __ComponentObjects = ∂
  86.         "{_FWObjDir}"SOMPart.cpp.o
  87.  
  88. You also need to add dependency rules, like this:
  89.  
  90. "{_FWTargetDir}MyInterface.xih" ƒ "{_FWTargetDir}MyInterface.idl"
  91.  
  92. "{_FWTargetDir}MyInterface.xh" ƒ "{_FWTargetDir}MyInterface.idl"
  93.  
  94. "{_FWTargetDir}MyInterface.cpp" ƒ "{_FWTargetDir}MyInterface.idl" ∂
  95.         "{_FWTargetDir}MyInterface.xh" ∂
  96.         "{_FWTargetDir}MyInterface.xih"
  97.  
  98. • Run FWBuild
  99.  
  100. You are finally ready to build. In the MPW Worksheet, type this:
  101. (substitute MyPart with your part's folder's name)
  102. FWBuild -Metrowerks "{ODFDev}MyPart:Sources:MyPart.SOM"
  103.  
  104. You must have your part's folder in the same folder as ODF for this to work. This is required anyway because some ODF scripts have relative paths.
  105.  
  106. FWBuild will run somc to output your .cpp, .xh, and .xih files. At this point you can implement your extension. If you change your .idl file, you need to do this step over again (but only this step). When the SOM compiler writes your .cpp file it will not delete anything, so you don't need to worry about saving code. It rewrites, not replaces, the .cpp file. In some cases it will create a new set of methods (for instance, if you rename your SOM class); other times it fixes prototypes for you, and even inserts comments telling you what it did. Sounds scary, but it works fine. 
  107.  
  108. Common Problems
  109.  
  110. You may get "include file not found" errors. This would mean that you are trying to #include other .idl files which are not found in the standard OpendDoc or ODF set. You will need to add the locations of those other .idl files to the makefile. For example, if you were building Cyberdog parts you would probably have put the PublicIncludes folder in your CodeWarrior folder, and would need to change the include listing like this:
  111.  
  112. __IDLIncludeDirs = d
  113.         -I "HD:CodeWarrior:MacOS Support:Headers:PublicIncludes:" d
  114.         -I "{FWODIDLIncludes}"
  115.  
  116. © 1993 - 1996 Apple Computer, Inc. All rights reserved.
  117. Apple, the Apple Logo, Macintosh, and OpenDoc are trademarks of Apple Computer, Inc., registered in the United States and other countries.